home *** CD-ROM | disk | FTP | other *** search
- /*
- * RING.C
- *
- * ring buffer routines
- *
- */
-
- #include "char.h"
-
- /*
- * r_write()
- *
- * r_write() puts a byte in the buffer. when is the buffer full?
- * when writing 1 more byte would set the read and write indices
- * equal to each other (which means the buffer is empty!!). does
- * nothing but return if it can't write the byte without
- * overflowing the buffer... if this was a real multi-tasking
- * system, we could sleep until somebody reads a byte, which
- * would allow us to do our write, but it isn't, so...
- */
-
- void r_write(c)
- char c;
- {
- if (((w_index + 1) & RLIMIT) == r_index)
- return;
- r_buf[ w_index++ ] = c;
- w_index &= RLIMIT; /* wrap the index around */
- }
-
-
- /*
- * r_puti()
- *
- * r_puti() converts a small (0 - 99) decimal number into two
- * ASCII digits and put them in the ring buffer
- */
-
- void r_puti(c)
- char c;
- {
- r_write((c / 10) + '0');
- r_write((c % 10) + '0');
- }
-
-